const  { Layout, notification, Icon } = antd;
const { Content, Footer } = Layout;
console.log(Layout);
console.log(notification);
console.log(Icon);
const {BrowserRouter} = ReactRouterDOM;
const Router = BrowserRouter;
function receiveData() {
    return;
}

class App extends React.Component {
    constructor() {
        super();
        this.state = {
            collapsed: false,
        };
    }
    componentWillMount() {
        const user = JSON.parse(localStorage.getItem('user'));
        user && receiveData(user, 'auth');
        // receiveData({a: 213}, 'auth');
        // fetchData({funcName: 'admin', stateName: 'auth'});
        this.getClientWidth();
        window.onresize = () => {
            console.log('屏幕变化了');
            this.getClientWidth();
            // console.log(document.body.clientWidth);
        }
    }
    componentDidMount() {
        const openNotification = () => {
            notification.open({
                message: '博主-yezihaohao',
                description: (
                    <div>
                        <embed src={"qklogo.svg"} type={"image/svg+xml"} />
                        <p>
                            GitHub地址： <a href="https://github.com/yezihaohao" target="_blank" rel="noopener noreferrer">https://github.com/yezihaohao</a>
                        </p>
                        <p>
                            博客地址： <a href="https://yezihaohao.github.io/" target="_blank" rel="noopener noreferrer">https://yezihaohao.github.io/</a>
                        </p>
                    </div>
                ),
                icon: <Icon type="smile-circle" style={{ color: 'green' }} />,
                duration: 0,
            });
            localStorage.setItem('isFirst', JSON.stringify(true));
        };
        const isFirst = JSON.parse(localStorage.getItem('isFirst'));
        //!isFirst && openNotification();
        openNotification();
    }
    getClientWidth = () => {    // 获取当前浏览器宽度并设置responsive管理响应式
        const clientWidth = document.body.clientWidth;
        console.log(clientWidth);
        receiveData({isMobile: clientWidth <= 992}, 'responsive');
    };
    toggle = () => {
        this.setState({
            collapsed: !this.state.collapsed,
        });
    };
    render(){
        return (
            <Router>
                <Layout>
                    <SiderCustom collapsed={this.state.collapsed} />
                    <Layout style={{flexDirection: 'column'}}>
                        <Content style={{ margin: '0 16px', overflow: 'initial' }}>
                            <CRouter />
                        </Content>
                        <Footer style={{ textAlign: 'center' }}>
                            <div><embed src={"qklogo.svg"} type={"image/svg+xml"} /></div>
                            桥康智能 ©2015- Created by yao_yu@126.com
                        </Footer>
                    </Layout>

                </Layout>
            </Router>
        );
    }
}